package com.fate.framework.vo.log;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * @Author: ten.x @TableName sys_log @Date: 2024-08-09 09:09:51 @Version: V1.0
 */
@Data
@Accessors(chain = true)
@TableName(value = "sys_log")
@EqualsAndHashCode(callSuper = false)
public class LogDetailVO implements Serializable {

  @Serial
  @TableField(exist = false)
  private static final long serialVersionUID = 1L;

  /** 主键：ID */
  @TableId
  @Schema(description = "ID")
  private String id;

  /** 日志类型 */
  @NotBlank(message = "[日志类型]不能为空")
  @Size(max = 50, message = "编码长度不能超过50")
  @TableField(value = "log_type")
  @Schema(description = "日志类型")
  @Length(max = 50, message = "编码长度不能超过50")
  private String logType;

  /** 创建用户编码 */
  @NotBlank(message = "[创建用户编码]不能为空")
  @Size(max = 64, message = "编码长度不能超过64")
  @TableField(value = "create_user_code")
  @Schema(description = "创建用户编码")
  @Length(max = 64, message = "编码长度不能超过64")
  private String createUserCode;

  /** 创建用户名称 */
  @NotBlank(message = "[创建用户名称]不能为空")
  @Size(max = 100, message = "编码长度不能超过100")
  @TableField(value = "create_user_name")
  @Schema(description = "创建用户名称")
  @Length(max = 100, message = "编码长度不能超过100")
  private String createUserName;

  /** 创建时间 */
  @NotNull(message = "[创建时间]不能为空")
  @TableField(value = "create_date")
  @Schema(description = "创建时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime createDate;

  /** 请求URI */
  @Size(max = 500, message = "编码长度不能超过500")
  @TableField(value = "request_uri")
  @Schema(description = "请求URI")
  @Length(max = 500, message = "编码长度不能超过500")
  private String requestUri;

  /** 请求方式 */
  @Size(max = 10, message = "编码长度不能超过10")
  @TableField(value = "request_method")
  @Schema(description = "请求方式")
  @Length(max = 10, message = "编码长度不能超过10")
  private String requestMethod;

  /** 请求参数 */
  @TableField(value = "request_params")
  @Schema(description = "请求参数")
  private String requestParams;

  /** 请求IP */
  @NotBlank(message = "[请求IP]不能为空")
  @Size(max = 20, message = "编码长度不能超过20")
  @TableField(value = "request_ip")
  @Schema(description = "请求IP")
  @Length(max = 20, message = "编码长度不能超过20")
  private String requestIp;

  /** 请求服务器地址 */
  @NotBlank(message = "[请求服务器地址]不能为空")
  @Size(max = 50, message = "编码长度不能超过50")
  @TableField(value = "server_address")
  @Schema(description = "请求服务器地址")
  @Length(max = 50, message = "编码长度不能超过50")
  private String serverAddress;

  /** 是否异常 */
  @TableField(value = "is_exception")
  @Schema(description = "是否异常")
  private Boolean isException;

  /** 异常信息 */
  @TableField(value = "exception_info")
  @Schema(description = "异常信息")
  private String exceptionInfo;

  /** 开始时间 */
  @NotNull(message = "[开始时间]不能为空")
  @TableField(value = "start_time")
  @Schema(description = "开始时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime startTime;

  /** 结束时间 */
  @NotNull(message = "[结束时间]不能为空")
  @TableField(value = "end_time")
  @Schema(description = "结束时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime endTime;

  /** 执行时间 */
  @TableField(value = "execute_time")
  @Schema(description = "执行时间")
  private Long executeTime;

  /** 用户代理 */
  @Size(max = 500, message = "编码长度不能超过500")
  @TableField(value = "user_agent")
  @Schema(description = "用户代理")
  @Length(max = 500, message = "编码长度不能超过500")
  private String userAgent;

  /** 操作系统 */
  @Size(max = 100, message = "编码长度不能超过100")
  @TableField(value = "device_name")
  @Schema(description = "操作系统")
  @Length(max = 100, message = "编码长度不能超过100")
  private String deviceName;

  /** 浏览器名称 */
  @Size(max = 100, message = "编码长度不能超过100")
  @TableField(value = "browser_name")
  @Schema(description = "浏览器名称")
  @Length(max = 100, message = "编码长度不能超过100")
  private String browserName;
}
